/**
 * 
 */
package org.cuatrovientos.vehicle;

import java.util.Vector;

/**
 * Death race
 * @author Isma
 *
 */
public class Race {
	private String name;
	private Circuit losArcos;
	private Vector<Car> competitor = new Vector<Car>();
	
	
	/**
	 * @return the name
	 */
	public String getName() {
		return name;
	}


	/**
	 * @param name the name to set
	 */
	public void setName(String name) {
		this.name = name;
	}


	/**
	 * constructor
	 * @param name
	 * @param losArcos
	 */
	public Race(String name, Circuit losArcos) {
		super();
		this.name = name;
		this.losArcos = losArcos;
	}
	/**
	 * Add new car
	 * @param c
	 */
	public void addCar(Car c){
		competitor.add(c);
	}
	/**
	 * method that give us the winner of the race
	 * @return
	 */
	public Car run(){
		float winner=0;
		float looser;
		int nWinner=0;
		for (int i=0;i <competitor.size();i++){//porke i = 1?
			looser = losArcos.getKilometers()/competitor.get(i).move();
			if (winner ==0){
				winner = looser;
			}
			if (winner > looser){
				winner = looser;
				nWinner = i;
			}
			
		}
		return competitor.get(nWinner);
	}

}
